#pragma once
#include"RBTree.h"
namespace bit
{
	template<class K, class V>
	class Mymap
	{
	public:
		struct KeyofT
		{
			const K& operator()(const pair<K,V>& _kv)
			{
				return _kv.first;
			}
		};
		typedef  typename  RBTree<K, pair<const K,V>, KeyofT>::iterator  iterator;
		typedef  typename  RBTree<K, pair<const K, V>, KeyofT>::const_iterator  const_iterator;
		iterator begin()
		{
			return root.begin();
		}
		iterator end()
		{
			return root.end();
		}
		const_iterator begin()const
		{
			return root.begin();
		}
		const_iterator end()const
		{
			return root.end();
		}
		pair<iterator, bool> insert(const pair<K,V>& _kv )
		{
			return root.Insert(_kv);
		}
		V& operator[](const K& key)
		{
			pair<iterator, bool> it = insert(make_pair(key, V()));
			return it.first->second;
		}
	private:
		RBTree<K, pair<const K, V>, KeyofT> root;
	};
}